package cn.kgc.mes.productreceptline.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.kgc.mes.common.annotation.Log;
import cn.kgc.mes.common.core.controller.BaseController;
import cn.kgc.mes.common.core.domain.AjaxResult;
import cn.kgc.mes.common.enums.BusinessType;
import cn.kgc.mes.productreceptline.domain.ProductRecptLine;
import cn.kgc.mes.productreceptline.service.IProductRecptLineService;
import cn.kgc.mes.common.utils.poi.ExcelUtil;
import cn.kgc.mes.common.core.page.TableDataInfo;

/**
 * 产品入库记录行Controller
 * 
 * @author ruoyi
 * @date 2025-09-21
 */
@RestController
@RequestMapping("/productreceptline/productreceptline")
public class ProductRecptLineController extends BaseController
{
    @Autowired
    private IProductRecptLineService productRecptLineService;

    /**
     * 查询产品入库记录行列表
     */
//    @PreAuthorize("@ss.hasPermi('productreceptline:productreceptline:list')")
    @GetMapping("/list")
    public TableDataInfo list(ProductRecptLine productRecptLine)
    {
        startPage();
        List<ProductRecptLine> list = productRecptLineService.selectProductRecptLineList(productRecptLine);
        return getDataTable(list);
    }

    /**
     * 导出产品入库记录行列表
     */
//    @PreAuthorize("@ss.hasPermi('productreceptline:productreceptline:export')")
    @Log(title = "产品入库记录行", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProductRecptLine productRecptLine)
    {
        List<ProductRecptLine> list = productRecptLineService.selectProductRecptLineList(productRecptLine);
        ExcelUtil<ProductRecptLine> util = new ExcelUtil<ProductRecptLine>(ProductRecptLine.class);
        util.exportExcel(response, list, "产品入库记录行数据");
    }

    /**
     * 获取产品入库记录行详细信息
     */
//    @PreAuthorize("@ss.hasPermi('productreceptline:productreceptline:query')")
    @GetMapping(value = "/{lineId}")
    public AjaxResult getInfo(@PathVariable("lineId") Long lineId)
    {
        return success(productRecptLineService.selectProductRecptLineByLineId(lineId));
    }

    /**
     * 新增产品入库记录行
     */
//    @PreAuthorize("@ss.hasPermi('productreceptline:productreceptline:add')")
    @Log(title = "产品入库记录行", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProductRecptLine productRecptLine)
    {
        return toAjax(productRecptLineService.insertProductRecptLine(productRecptLine));
    }

    /**
     * 修改产品入库记录行
     */
//    @PreAuthorize("@ss.hasPermi('productreceptline:productreceptline:edit')")
    @Log(title = "产品入库记录行", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProductRecptLine productRecptLine)
    {
        return toAjax(productRecptLineService.updateProductRecptLine(productRecptLine));
    }

    /**
     * 删除产品入库记录行
     */

    @Log(title = "产品入库记录行", businessType = BusinessType.DELETE)
	@DeleteMapping("/{lineIds}")
    public AjaxResult remove(@PathVariable Long lineIds)
    {
        return toAjax(productRecptLineService.deleteProductRecptLineByLineId(lineIds));
    }
}
